#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
#define popCnt(x) (__builtin_popcountll(x)) //calc num of 1's in binary
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long
#define ii pair<int,int>
const int INF = 1e9 + 5, N = 1000005, mod = 1e9 + 7;
int add(int a, int b) {
a = (0LL + a + mod) % mod;
b = (0LL + b + mod) % mod;
return (a + b) % mod;
}
int mul(int a, int b) {
a %= mod;
b %= mod;
return (1LL * a * b) % mod;
}
int fac[N];
void pre() {
fac[0] = 1;
for (int i = 1; i < N; i++)
fac[i] = mul(fac[i - 1], i);
}
int fastPow(int base, int power) {
if (base == 1 or power == 0)
return 1;
int halfPower = fastPow(base, power / 2);
int ans = mul(halfPower, halfPower);
if (power % 2 == 1)
ans = mul(ans, base);
return ans;
}
int modInverse(int x) {
return fastPow(x, mod - 2);
}
int nPr(int n, int r) {
return mul(fac[n], modInverse(fac[n - r]));
}
int nCr(int n, int r) {
return mul(fac[n], modInverse(mul(fac[n - r],
fac[r])));
}
#define int ll
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
//freopen((s + ".out").c_str(), "w", stdout);
}
int32_t main() {
fast;
int t;
cin >> t;
while (t--) {
int n, x;
cin >> n;
int e = 0, ans = 0;
map<int, int> mp;
for (int i = 0; i < n; i++) {
cin >> x;
if (x % 2 == 0)e++;
ans += mp[x];
mp[x]++;
}
ans += mp[1] * mp[2];
cout << ans << "\n";
}
return 0;
}
71. Simplify Path | 62. Unique Paths |
50. Pow(x, n) | 43. Multiply Strings |
34. Find First and Last Position of Element in Sorted Array | 33. Search in Rotated Sorted Array |
17. Letter Combinations of a Phone Number | 5. Longest Palindromic Substring |
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |